package com.zwface.demo.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.blankj.utilcode.util.StringUtils;

/**
 *
 */

public class SharedPreferenceUtils
{
    private static final String FILE_NAME = "jszhaopin";
    public static String ACCESS_TOKEN = "accessToken";
    public static String REFRESH_TOKEN = "refreshToken";
    public static String USER_TYPE = "userType";
    public static String USER_NAME = "userName";
    public static String USER_STUNO = "userNo";
    public static String USER_FACE = "userFace";
    public static String USER_ID = "userid";
    public static String AGREEMENT_USER = "agreementUser";//用户协议
    public static String AGREEMENT_PRIVACY = "agreementPrivacy";//隐私协议

    /**
     * 保存数据
     * @param context
     * @param key
     * @param value
     */
    public static void setParam(Context context ,String key, String value){

        SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();

        editor.putString(key, value);
        editor.commit();
    }

    /**
     * 得到保存数据
     * @param context
     * @param key
     * @return
     */
    public static String getParam(Context context , String key){
        SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
        return StringUtils.isEmpty(sp.getString(key, null)) ?"":sp.getString(key, null);
    }
}
